/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.upc.sistemaventas.web;
import edu.upc.sistemaventas.negocio.EmprendedorLogicaNegocio;
import edu.upc.sistemaventas.dominio.EmprendedorDomain;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author WDELGADO
 */
@Controller
public class RegistraSabioController {
    @RequestMapping(value = "/sabio", method = RequestMethod.GET)	
	protected ModelAndView inicio(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		return new ModelAndView("registrarsabio");
	}
    
    
    @RequestMapping(value = "/grabar", method = RequestMethod.POST)	
	protected ModelAndView grabar(HttpServletRequest request, HttpServletResponse response) throws Exception {
		//EmprendedorDomain notMNoti = (EmprendedorDomain)command;
                EmprendedorLogicaNegocio negocio = new EmprendedorLogicaNegocio();
                              
                
                ////
                EmprendedorDomain notMNoti2 = new EmprendedorDomain();
                
                notMNoti2.setNombres(request.getParameter("usuario").toString());
                notMNoti2.setApellidoPaterno(request.getParameter("paterno").toString());
                notMNoti2.setApellidoMaterno(request.getParameter("materno").toString());
                notMNoti2.setSexo(request.getParameter("sexo").toString());
                notMNoti2.setTipoDocumentoIdentidad(request.getParameter("tipodocumento").toString());
                notMNoti2.setNumeroDocumentoIdentidad(request.getParameter("numerodocumento").toString());
                notMNoti2.setCorreo(request.getParameter("correo").toString());
                notMNoti2.setCelular(request.getParameter("celular").toString());
                notMNoti2.setDireccion(request.getParameter("direccion").toString());
                //notMNoti2.setFechaNacimiento(request.getAttribute("fechanacimiento"));

                SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
                Date fecha;
                fecha = df.parse(request.getParameter("fechanacimiento").toString());
                
                notMNoti2.setFechaNacimiento(fecha);
                
                notMNoti2.setClave(request.getParameter("contrasenia").toString());
                //notMNoti2.set(request.getAttribute("apelativo").toString());
                //notMNoti2.set(request.getAttribute("resumen").toString());
                //notMNoti2.setDireccion(request.get    Attribute("sitioweb").toString());
                
                
                negocio.registrarEmprendedor(notMNoti2);
                //negocio.reg
		return new ModelAndView("grabar");
	}
    

}
